import { defineStore } from 'pinia'
import {  getSearchNewGoodsListAll, getSearchSellGoodsListAll, getSearchSynGoodsListAll} from '@/api'

export const useDetail = defineStore('detail-list', {
  state() {
    return {
      // 综合
      sell: [],
      // 销量
      syn: [],
      // 新品
      new: []
    }
  },
  getters: {
    // 全部数据
    combinedList(state) {
      return [...state.sell, ...state.syn, ...state.new]
    }
  },

  actions: {
    async getSellList() {
      const { data }: any = await getSearchSellGoodsListAll()
      this.sell = data
    },

    async getNewList() {
      const { data }: any = await getSearchNewGoodsListAll()
      this.new = data
    },

    async getSynList() {
      const { data }: any = await getSearchSynGoodsListAll()
      this.syn = data
    }
  }
})
